package com.threebrothers.lib_log.logger

import android.util.Log
import com.threebrothers.lib_log.LoggerLevel



class LoggerCatLogger : ILogger {
    /**
     * 日志打印
     */
    private var isDebug = true//是否debug
    private var TAG =""//默认TAG
    private var level  = LoggerLevel.Debug//默认级别
    private var url = ""//保存地址
    private var loggerFormat ="%s=====>%s"

    override fun d(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.Debug.value){
            Log.d(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun v(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.Verbose.value){
            Log.v(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun i(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.Info.value){
            Log.v(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun w(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.Warn.value){
            Log.v(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun e(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.Error.value){
            Log.v(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLogTAG(TAG: String) {
        this.TAG = TAG
    }

    override fun setLoggerLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setSaveUrl(url: String) {
        this.url = url
    }
}